package own.zip;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.zip.Deflater;

import own.utils.FileUtils;

public class Lz77 {

	public static byte[] compress(byte input[]) {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Deflater compressor = new Deflater(1);
        try {
            compressor.setInput(input);
            compressor.finish();
            final byte[] buf = new byte[2048];
            while (!compressor.finished()) {
                int count = compressor.deflate(buf);
                bos.write(buf, 0, count);
            }
        } finally {
            compressor.end();
        }
        return bos.toByteArray();
    }
	
	public static void main(String[] args) {
		File file1=new File("E:\\A1.JPG");
		FileUtils.getFile(FileUtils.getBytes("E:\\A.jpg"), file1);
		
		FileUtils.getFile("112233", new File("E:\\1.txt"));
	}

}
